import { ref, watch, reactive, getCurrentInstance } from "vue"
import request from '@/utils/request'
export const operationItem = reactive({
	defaultSearch: true,//默认搜索按钮
	defaultRefresh: true,//默认重置按钮
	customTableHeader: false,//
	SearchItem: [
		{
			code: 'name',
			name: '名称',
			type: 'input',
			placeholder: '请输入名称',
		},
		{
			code: 'courseType',
			name: '课程类型',
			type: 'cascader',
			props: {label:'name',value:'id',children:'children',emitPath:false}
		},
		{
			code: 'type',
			name: '类型',
			type: 'select',
		},
		{
			code: 'teacherId',
			name: '讲师',
			type: 'select',
		},
		{
			code: 'publishedFlag',
			name: '上架状态',
			type: 'select',
			placeholder: '请选择状态',
			options: [
				{ label: '上架', value: 1 },
				{ label: '下架', value: 0 }
			]
		},
		{
			code: 'playbackFlag',
			name: '是否回放',
			type: 'select',
			placeholder: '请选择是否回放',
			options: [
				{ label: '是', value: 1 },
				{ label: '否', value: 0 }
			]
		},
		{
			code: ['startTime',
				'endTime',], //
			startName: '开始时间', //默认是开始时间 type为 daterange生效
			rangeName: '', //默认是至 type为 daterange生效
			endName: '结束时间', //默认是结束时间 type为 daterange生效
			valueFormat: 'YYYY-MM-DD HH:mm:ss', //默认是YYYY-MM-DD
			placeholder: '请选择时间', //默认是请选择日期type为date生效
			type: 'daterange', //daterange或date
		},
	],
	menuArray: [
		{
			show: true,
			code: 'del',
			type: 'danger',
			text: '批量删除',
		},
		{
			show: true,
			code: 'add',
			type: 'primary',
			text: '新建',
		},
		{
			show: true,
			code: 'import',
			type: 'primary',
			text: '导入',
		},
		{
			show: true,
			code: 'playback',
			type: 'primary',
			text: '导入回放',
		},
		{
			show: true,
			code: 'export',
			type: 'primary',
			text: '导出',
		},
	],
})
export const tableItem = reactive({
	select: true,//多选框
	index: false,//顺序
	expandAll: false,//树形默认展开
	align: 'center',
	column: [
		{
			label: '名称',
			prop: 'name',
		},
		{
			label: '课程类型',
			prop: 'courseTypeName',
		},
		{
			label: '类型',
			prop: 'typeName',
		},
		{
			label: '讲师',
			prop: 'teacherName',
		},
		{
			label: '资料',
			prop: 'docName',
		},
		{
			label: '练习库',
			prop: 'bankName',
		},
		{
			label: '直播url',
			prop: 'url',
		},
		{
			label: '状态',
			htmlContent: row => {
				return `<span>${row.publishedFlag == 1? '上架' : '下架'}</span>`
			},
		},
		{
			label: '课程时间',
			tooltip: true,
			htmlContent: row => {
				return `<span>${row.startTime + '至' + row.endTime}</span>`
			},
		},
		{
			label: '操作',
			prop: 'action',
			width: '200px',
		}
	],
	pageInfo: {
		request: {
			pageDomain:{}
		},
		pagesClose: false,//是否开启分页
		url: '/admin/resource/course/live/paging',//分页路由，不传的话需要传入自定义的分页函数paging 传入时定义的分页函数paging会失效
	},
	// 分页数据 自定义分页函数paging时需要把值赋给tableData
	tableData: {
		total: 10,//分页总计
		// 分页数据
		data: []
	},
	// 操作栏按钮
	btnArray: [
		{
			type: 'primary',//类别 摈弃了text
			code: 'detail',
			label: '详情',
		},
		{
			type: 'primary',//类别 摈弃了text
			label: '修改',
			code: 'edit',
		},
		{
			type: 'primary',//类别 摈弃了text
			label: '上架',
			code: 'published',
			showFunction: (row)=>{
				return row.publishedFlag == 0;
			},
		},
		{
			type: 'danger',//类别 摈弃了text
			label: '下架',
			code: 'unpublished',
			showFunction: (row)=>{
				return row.publishedFlag == 1;
			},
		},
	],
	// 选择框触发
	selectChange: function (row) {},
})
